package com.xpffly.design.mediator.service.impl;

import cn.hutool.core.util.RandomUtil;
import com.xpffly.design.mediator.service.AbstractColleague;
import com.xpffly.design.mediator.service.AbstractMediator;

/**
 * @Author: xpengfei
 * @Date: 2021/4/5 20:08
 * @Description：销售管理
 */
public class Sale extends AbstractColleague {
    public Sale(AbstractMediator mediator) {
        super(mediator);
    }

    /**
     * 销售IBM电脑
     *
     * @param number
     */
    public void sellIBMComputer(int number) {
        System.out.println("销售IBM电脑" + number + "台");
        super.mediator.execute("sale.sell", number);
    }

    /**
     * 反馈销售情况
     *
     * @return 0--100之间， 0：无人购买，100：非常畅销
     */
    public int getSaleStatus() {
        int saleStatus = RandomUtil.randomInt(0, 100);
        System.out.println("IBM销售情况为：" + saleStatus);
        return saleStatus;
    }

    /**
     * 折价处理
     */
    public void offSale() {
        super.mediator.execute("sale.offSell");
    }
}
